<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:>
<meta charset="utf-8">
<head th:include="include :: header"></head>
<style>
    .queueList {
        height: 270px;
    }

    .form-group {
        width: 700px;
        text-align: center;
    }
</style>
<link th:href="@{/css/plugins/webuploader/webuploader.css}" rel="stylesheet"/>
<link th:href="@{/css/demo/webuploader-demo.css}" rel="stylesheet"/>
<link th:href="@{/ajax/libs/iCheck/custom.css}" rel="stylesheet"/>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-products-edit" th:object="${products}">
        <input id="id" name="id" th:field="*{id}" type="hidden">
        <div class="col-md-6">
            <div class="form-group">
                <img th:src='@{/profile/product/}+*{picUrl}' width="60px" height="60px;">
            </div>
        </div>

        <div class="col-md-6">
            <div class="form-group">
                <label class="col-sm-3 control-label"><span class="must_be_color">*</span>mainSKU：</label>
                <div class="col-sm-9">
                    <input type="text" name="mainSKU" class="form-control" th:field="*{mainSKU}" disabled
                           placeholder="Please enter text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label"><span class="must_be_color">*</span>productName：</label>
                <div class="col-sm-9">
                    <input type="text" name="productName" th:field="*{productName}" class="form-control" disabled
                           placeholder="Please enter text">
                </div>
            </div>

        </div>
        <div class="col-md-6">
            <div class="form-group">
                <label class="col-sm-3 control-label">inventoryQuantity：</label>
                <div class="col-sm-9">
                    <input type="text" id="shareQuantity" name="shareQuantity" th:field="*{shareQuantity}"
                           class="form-control" autocomplete="off">
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="form-control-static col-sm-offset-9">
                <button type="submit" class="btn btn-primary">submit</button>
                <button onclick="$.modal.close()" class="btn btn-danger" type="button">close</button>
            </div>
        </div>
    </form>
</div>
<div th:include="include::footer"></div>
<div th:include="include::footer"></div>
<script th:src="@{/ajax/libs/select/select2.js}"></script>
<script type="text/javascript">

    $("#form-products-edit").validate({
        rules: {
            mainSKU: {
                required: true,
            },
            productName: {
                required: true,
            }
        },
        submitHandler: function (form) {
            edit();
        }
    });

    function edit () {
        var id = $("input[name='id']").val();
        var shareQuantity = $("input[name='shareQuantity']").val();
        $.ajax({
            cache: true,
            type: "POST",
            url: ctx + "module/products/edit",
            data: {
                "id": id,
                "shareQuantity": shareQuantity,
            },
            async: false,
            error: function (request) {
                $.modal.alertError("system error");
            },
            success: function (data) {
                $.operate.saveSuccess(data);
            }
        });
    }

</script>

</body>
</html>
